package com.yyx.app1.MedicationAssistant_function.Controls.SearchDrup_Activity_Control.HotSearch_ListView;

import android.content.Context;
import android.database.Cursor;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created by yuexing on 2015/9/8.
 */
public class HotSearch_ListView_Adapter extends BaseAdapter {
    private Context context;
    private List<HashMap<String,String>> map;

    public HotSearch_ListView_Adapter(Context context) {
        this.context = context;
    }

    public void findAll(List<HashMap<String,String>> list)
    {
        if (list!=null)
            map = list;
        this.notifyDataSetChanged();
    }

    public void findAll()
    {
//        map=new ArrayList<>();
//        for (int i=0;i<10 ;++i)
//        {
//            map.add("321321");
//        }
    }

    @Override
    public int getCount() {
        return map.size();
    }

    @Override
    public Object getItem(int position) {
        return map.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ItemView_HotSearch_ListView it;
        if (convertView==null)
        {
            it=ItemView_HotSearch_ListView_.build(context);
        }
        else
        {
            it=(ItemView_HotSearch_ListView)convertView;
        }
        it.bind(map.get(position).get("medicineName"),map.get(position).get("englishName"),map.get(position).get("indication"),null);
        return it;
    }
}
